package com.powernode.controller;

import com.github.pagehelper.PageInfo;
import com.powernode.domain.ActivityRemark;
import com.powernode.model.R;
import com.powernode.service.ActivityRemarkService;
import com.powernode.vo.ActivityRemarkVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 市场活动备注接口管理
 */
@RestController
@RequestMapping("/api/activity/remark")
public class ActivityRemarkController {

    @Autowired
    private ActivityRemarkService activityRemarkService;

    /**
     * 根据市场活动标识分页查询市场活动备注列表
     * @param current
     * @param size
     * @param activityId
     * @return
     */
    @GetMapping("/page")
    public R<PageInfo<ActivityRemarkVo>> loadActivityRemarkPage(@RequestParam Integer current,
                                                                @RequestParam(required = false,defaultValue = "10") Integer size,
                                                                @RequestParam Integer activityId) {
        PageInfo<ActivityRemarkVo> pageInfo = activityRemarkService.queryActivityRemarkInfoPage(current,size,activityId);
        return R.OK(pageInfo);
    }

    /**
     * 新增市场活动备注
     * @param activityRemark
     * @return
     */
    @PostMapping
    public R<String> saveActivityRemark(@RequestBody ActivityRemark activityRemark) {
        Boolean saved = activityRemarkService.saveActivityRemark(activityRemark);
        return R.HANDLER(saved);
    }


    /**
     * 修改市场活动备注
     * @param activityRemark
     * @return
     */
    @PutMapping
    public R<String> modifyActivityRemark(@RequestBody ActivityRemark activityRemark) {
        Boolean modified = activityRemarkService.modifyActivityRemark(activityRemark);
        return R.HANDLER(modified);
    }

    /**
     * 根据标识删除市场活动备注
     * @param remarkId
     * @return
     */
    @DeleteMapping("/{remarkId}")
    public R<String> removeActivityRemark(@PathVariable Integer remarkId) {
        Boolean removed = activityRemarkService.removeActivityRemarkById(remarkId);
        return R.OK(null);
    }
}
